! Bessel K_1(x) function in double precision
!
      function dbesk1(x)
      implicit real*8 (a - h, o - z)
      dimension a(0 : 15), b(0 : 119), c(0 : 119), d(0 : 39)
      data (a(i), i = 0, 15) / 
     &    1.5151605362537935201d-13, 3.3637909513536510350d-11, 
     &    5.6514041131016827202d-9, 6.7816840255069534052d-7, 
     &    5.4253472222259226487d-5, 2.6041666666666637057d-3, 
     &    6.2500000000000000090d-2, 5.0000000000000000000d-1, 
     &    -8.9790303384748696588d-11, -1.4029047449249185771d-8, 
     &    -1.5592893752540998113d-6, -1.1253607018469017569d-4, 
     &    -4.6421827665011579173d-3, -8.5370719728648409609d-2, 
     &    -3.0796575782920629660d-1, 1.0000000000000000004d0 / 
      data (b(i), i = 0, 14) / 
     &    -9.4055461896630579928d-12, 3.1307934665844664773d-11, 
     &    4.2005295001519243251d-10, -4.1636196779679820012d-9, 
     &    1.4483026181700966164d-8, 1.1661000205428816914d-8, 
     &    -3.5023996724943046209d-7, 1.4404279316339005012d-6, 
     &    5.3581564157158242080d-7, -3.5249754038612334639d-5, 
     &    1.7150324075631641453d-4, -4.1276362611239191024d-5, 
     &    -4.6943110979636602591d-3, 3.5085369853392357659d-2, 
     &    2.0063574339907819159d-1 / 
      data (b(i), i = 15, 29) / 
     &    3.3998989888944034586d-11, 7.1558979072937373055d-11, 
     &    -2.9226856932927698732d-9, 1.4591620256525610213d-8, 
     &    -6.6141635609854161666d-9, -1.9991101838984472332d-7, 
     &    5.9185836628873530572d-7, 1.9562880347358085687d-6, 
     &    -1.5814366450418102764d-5, 7.6791682910944612028d-6, 
     &    2.8354678948323983936d-4, -1.0217932669418690641d-3, 
     &    -3.2205661865210048433d-3, 4.3497494842354644077d-2, 
     &    1.6110284302315089935d-1 / 
      data (b(i), i = 30, 44) / 
     &    -2.0933987679665541827d-10, 7.9503322090520447316d-10, 
     &    3.8000150948242575774d-9, -2.3076136195585571309d-8, 
     &    -2.3902880302550799653d-8, 3.1914500937804377478d-7, 
     &    3.2639909831082417694d-7, -5.3166994792995439449d-6, 
     &    -3.1109524694269240094d-6, 9.2575906966353273247d-5, 
     &    7.5063709094147644746d-7, -1.7416491592625765379d-3, 
     &    1.2138560335171676007d-3, 4.5879687144659643175d-2, 
     &    1.1566544716132846709d-1 / 
      data (b(i), i = 45, 59) / 
     &    3.1582384905164908749d-10, -1.9959561818098999516d-9, 
     &    8.6959328920030927557d-10, 1.1642778282445577109d-8, 
     &    4.3552264337818440471d-8, -1.5057982160481803238d-7, 
     &    -1.0101729117980989857d-6, 7.7002002510177612013d-7, 
     &    1.9580574235590194233d-5, 1.9358461980242834361d-5, 
     &    -3.3932339942485532728d-4, -9.3416673584325090073d-4, 
     &    5.5800080455912847227d-3, 3.8668683062477179235d-2, 
     &    7.2651643500517000658d-2 / 
      data (b(i), i = 60, 74) / 
     &    -1.1554749629758510059d-10, 8.2270678758893273006d-10, 
     &    -5.0211156951551538591d-10, -1.4929179050554858361d-9, 
     &    -2.7107940791526366702d-8, -4.2204764086705349384d-8, 
     &    3.7253098167927628867d-7, 2.4374697215363361156d-6, 
     &    1.4141942006909768370d-6, -4.8766389019473918231d-5, 
     &    -2.1681387247526720978d-4, 2.9325729929653405236d-4, 
     &    6.4087534504827239815d-3, 2.6054628289709454356d-2, 
     &    4.0156431128194184336d-2 / 
      data (b(i), i = 75, 89) / 
     &    2.5506555170746221691d-11, -1.3521164018407978152d-10, 
     &    -8.3281235274106699399d-11, -9.7764849575562351891d-10, 
     &    3.4661828409940354542d-9, 3.9760633711791357544d-8, 
     &    1.5902906645504529930d-7, -1.4919441249454941275d-7, 
     &    -5.3779684992094351263d-6, -2.7513862296246223142d-5, 
     &    -9.7880089725297162007d-6, 7.0787668964515789714d-4, 
     &    4.6968199862345387583d-3, 1.4745740181663320127d-2, 
     &    2.0048622219583455723d-2 / 
      data (b(i), i = 90, 104) / 
     &    -3.4824483072529265585d-12, 1.5157161810563380451d-12, 
     &    8.5303859696700686144d-12, 3.3455414203743741076d-10, 
     &    2.0226016353844285376d-9, 5.3128154003266334990d-9, 
     &    -3.0799322316418042137d-8, -4.4455408272954712128d-7, 
     &    -2.4293274626893384034d-6, -3.2129079340119038354d-6, 
     &    5.9225403683075388850d-5, 5.6822962576781683532d-4, 
     &    2.7152446516406682732d-3, 7.4075873691848838485d-3, 
     &    9.3044450815739269849d-3 / 
      data (b(i), i = 105, 119) / 
     &    -2.7683216166276377232d-13, 3.1986676777610155465d-12, 
     &    9.4142986954031445666d-12, 6.7934609179456399334d-11, 
     &    3.4851529411470029330d-11, -2.5785248508896551557d-9, 
     &    -2.8310220027112571258d-8, -1.6384131113072271115d-7, 
     &    -3.2521663350596379097d-7, 4.0381388757622307160d-6, 
     &    5.1917606978077281001d-5, 3.3420027947470126154d-4, 
     &    1.3699550623118247094d-3, 3.4405619148342271096d-3, 
     &    4.1042919106665762794d-3 / 
      data (c(i), i = 0, 14) / 
     &    4.5281968025889407937d-12, 1.0806749918195271176d-11, 
     &    9.6200972728717669027d-11, 5.7214227063625263650d-10, 
     &    3.6077804282954825099d-9, 2.2465236858536681852d-8, 
     &    1.3676961264308735230d-7, 7.9561767489531997361d-7, 
     &    4.3014380065615550573d-6, 2.0921713905550285590d-5, 
     &    8.8079183950590176926d-5, 3.0549414408830252064d-4, 
     &    8.1295715613927890473d-4, 1.4679809476357079195d-3, 
     &    1.3439197177355090057d-3 / 
      data (c(i), i = 15, 29) / 
     &    7.6019964430402432637d-13, -2.2616198599158271190d-13, 
     &    1.7904450823779000744d-11, 9.1467054855312232717d-11, 
     &    7.1378582044879519122d-10, 4.9925255415445769102d-9, 
     &    3.3767315471315546644d-8, 2.1350774539167751457d-7, 
     &    1.2314353082655232903d-6, 6.2918685053670619181d-6, 
     &    2.7493229298777000013d-5, 9.8085825401369821771d-5, 
     &    2.6670282677770444935d-4, 4.8967895428135985381d-4, 
     &    4.5418248688489697144d-4 / 
      data (c(i), i = 30, 44) / 
     &    9.4180115230375147213d-14, 7.5943117003734061145d-14, 
     &    3.0335730243874287654d-12, 2.0202796115462268051d-11, 
     &    1.6839020189186971198d-10, 1.2907875663127201526d-9, 
     &    9.3547676125865798920d-9, 6.2471974110281880722d-8, 
     &    3.7585985422997380441d-7, 1.9838348288114906484d-6, 
     &    8.8884862203671982034d-6, 3.2333259238682810218d-5, 
     &    8.9266668913380400243d-5, 1.6589185669844051903d-4, 
     &    1.5536921180500113394d-4 / 
      data (c(i), i = 45, 59) / 
     &    1.5425475332301107271d-14, 2.8674534590132490434d-14, 
     &    6.5078462279160216936d-13, 5.0939757793961391211d-12, 
     &    4.4979837460748975520d-11, 3.6662925847520171711d-10, 
     &    2.7848878755089582413d-9, 1.9298120059339477820d-8, 
     &    1.1950323861976892013d-7, 6.4513432758147478287d-7, 
     &    2.9422095033982461936d-6, 1.0854433321174584937d-5, 
     &    3.0307433185818899481d-5, 5.6840981443065017850d-5, 
     &    5.3637016379451945253d-5 / 
      data (c(i), i = 60, 74) / 
     &    3.1077953698439839352d-15, 8.6899496170729520378d-15, 
     &    1.6258562067326054104d-13, 1.4104842571366761537d-12, 
     &    1.3019455544084110747d-11, 1.1070466372863950239d-10, 
     &    8.6890603844230597917d-10, 6.1793722175049967488d-9, 
     &    3.9058865943755615801d-8, 2.1432806981070368523d-7, 
     &    9.9034657762983230155d-7, 3.6925185861895664251d-6, 
     &    1.0399877577259449786d-5, 1.9644939661550210015d-5, 
     &    1.8648773453825584597d-5 / 
      data (c(i), i = 75, 89) / 
     &    7.2831555285336286457d-16, 2.6077534095895783532d-15, 
     &    4.4881202059263153495d-14, 4.1674329383944385626d-13, 
     &    3.9760100480223728037d-12, 3.4835976355351183010d-11, 
     &    2.7993254212770249700d-10, 2.0286513276830758107d-9, 
     &    1.3018343087118439152d-8, 7.2315927974997999365d-8, 
     &    3.3750708681924201599d-7, 1.2688020879407355571d-6, 
     &    3.5980954090811587848d-6, 6.8358260635246667316d-6, 
     &    6.5208606745808860557d-6 / 
      data (c(i), i = 90, 104) / 
     &    1.9026412343503745875d-16, 8.0073765508732553766d-16, 
     &    1.3245754278055523992d-14, 1.2885201653055058502d-13, 
     &    1.2600129301230402587d-12, 1.1283306843147549277d-11, 
     &    9.2261481309646814329d-11, 6.7812033168299846818d-10, 
     &    4.4020645304595102132d-9, 2.4685719238301517679d-8, 
     &    1.1611886719473112509d-7, 4.3940380936523135466d-7, 
     &    1.2529878285546791905d-6, 2.3917218527087570384d-6, 
     &    2.2907574647671878160d-6 / 
      data (c(i), i = 105, 119) / 
     &    5.3709522135744366512d-17, 2.5239221050372845433d-16, 
     &    4.0933147145899083360d-15, 4.1152784247617592367d-14, 
     &    4.0998840572769381012d-13, 3.7319354625807158852d-12, 
     &    3.0921671702920868014d-11, 2.2975898538634445343d-10, 
     &    1.5049754445782364328d-9, 8.5030864719789148982d-9, 
     &    4.0250559391118423810d-8, 1.5312755642491878591d-7, 
     &    4.3865020375297892208d-7, 8.4059737392822153101d-7, 
     &    8.0785884122023473319d-7 / 
      data (d(i), i = 0, 7) / 
     &    9.2371554649979581914d-14, -2.3111336195788410887d-12, 
     &    5.7728710326649832559d-11, -1.8002298130091372598d-9, 
     &    7.6810375010517145638d-8, -5.2669973752193823306d-6, 
     &    1.0112634961227401357d-3, 1.6180215937964160466d-1 / 
      data (d(i), i = 8, 15) / 
     &    6.1381146507252683381d-14, -2.1034499679806301862d-12, 
     &    5.7090233460448415278d-11, -1.7990724350642330817d-9, 
     &    7.6809056078388019946d-8, -5.2669964425290062357d-6, 
     &    1.0112634957478283390d-3, 1.6180215937970716383d-1 / 
      data (d(i), i = 16, 23) / 
     &    4.2458150578401296419d-14, -1.8435733128339016981d-12, 
     &    5.5534955081564656595d-11, -1.7938162188526358466d-9, 
     &    7.6798230945934117807d-8, -5.2669828728791921259d-6, 
     &    1.0112634861753356559d-3, 1.6180215938263409582d-1 / 
      data (d(i), i = 24, 31) / 
     &    3.0314798962267007518d-14, -1.5915009905364214455d-12, 
     &    5.3275907427402047438d-11, -1.7824862013841369751d-9, 
     &    7.6763890356447075810d-8, -5.2669199860465945909d-6, 
     &    1.0112634217687349189d-3, 1.6180215941108227283d-1 / 
      data (d(i), i = 32, 39) / 
     &    2.2211515002229271212d-14, -1.3664088221521734796d-12, 
     &    5.0585177270502341602d-11, -1.7645432205894533462d-9, 
     &    7.6691805594577373698d-8, -5.2667455286976269634d-6, 
     &    1.0112631862810974580d-3, 1.6180215954783127877d-1 / 
      if (x .lt. 0.8d0) then
          t = x * x
          y = (((((((a(0) * t + a(1)) * t + 
     &        a(2)) * t + a(3)) * t + a(4)) * t + 
     &        a(5)) * t + a(6)) * t + a(7)) * x
          y = (((((((a(8) * t + a(9)) * t + 
     &        a(10)) * t + a(11)) * t + a(12)) * t + 
     &        a(13)) * t + a(14)) * t + a(15)) / x + 
     &        y * log(x)
      else if (x .lt. 5.5d0) then
          v = 3 / x
          t = x - v
          k = int(t + 3)
          t = (k - 2) - t
          k = k * 15
          y = ((((((((((((((b(k) * t + b(k + 1)) * t + 
     &        b(k + 2)) * t + b(k + 3)) * t + b(k + 4)) * t + 
     &        b(k + 5)) * t + b(k + 6)) * t + b(k + 7)) * t + 
     &        b(k + 8)) * t + b(k + 9)) * t + b(k + 10)) * t + 
     &        b(k + 11)) * t + b(k + 12)) * t + b(k + 13)) * t + 
     &        b(k + 14)) * v
      else if (x .lt. 12.5d0) then
          k = int(x)
          t = (k + 1) - x
          k = 15 * (k - 5)
          y = (((((((((((((c(k) * t + c(k + 1)) * t + 
     &        c(k + 2)) * t + c(k + 3)) * t + c(k + 4)) * t + 
     &        c(k + 5)) * t + c(k + 6)) * t + c(k + 7)) * t + 
     &        c(k + 8)) * t + c(k + 9)) * t + c(k + 10)) * t + 
     &        c(k + 11)) * t + c(k + 12)) * t + c(k + 13)) * t + 
     &        c(k + 14)
      else
          t = 60 / x
          k = 8 * (int(t))
          y = (((((((d(k) * t + d(k + 1)) * t + 
     &        d(k + 2)) * t + d(k + 3)) * t + d(k + 4)) * t + 
     &        d(k + 5)) * t + d(k + 6)) * t + d(k + 7)) * 
     &        sqrt(t) * exp(-x)
      end if
      dbesk1 = y
      end
!
